#ifndef CMD_H
#define CMD_H


//#endif
#include "type.h"
#include "cli_main.h"
#include "xml_conf.h"
//CMD_TYPE

#define CMD_CTRL				0x1060
#define CMD_CONFIG				0x1061
#define CMD_SEARCH				0x1062
#define CMD_SYNC                0x1063
#define CMD_OTHERS              0x1064
//CMD_CTRL CODES
#define CT_RESRART				0x1070
#define CT_SLEEP				0x1071
#define CT_WAKEUP				0x1072
#define CT_WIRELISS_OFF			0x1073
#define CT_WIRELISS_ON			0x1074
#define CT_SMS_OFF				0x1075
#define CT_SMS_ON				0x1076
#define CT_SMS_SEND				0x1077
#define CT_SRV_UPDATA_OFF		0x1078
#define CT_SRV_UPDATA_ON		0x1079
#define CT_AIR_SNIFFER_OFF		0x107a
#define CT_AIR_SNIFFER_ON		0x107b
#define CT_TIME_SYNC			0x107c
#define CT_BBU_PW_OFF			0x107d
#define CT_BBU_PW_ON			0x107e
#define CT_RUNSTATS_ON			0x107f
#define CT_RUNSTATS_OFF			0x1080
#define CT_RESETTOFACTORY		0x1081
#define CT_SNIFFER				0x1082

#define CT_BBU_RESTART          0x1086
#define CT_SMS_MAIN_SWITCH      0x1085
#define CT_CLEAN_DATA	        0x10B1

#define CT_SET_BLACKLIST_ON     0x10d0
#define CT_SET_BLACKLIST_OFF    0x10d1

#define CT_BBU_SOFT_RESTART     0x1300
#define CT_PA_POWER_ON          0x1301
#define CT_PA_POWER_OFF         0x1302
#define CT_FTP_REPORT_ON        0x1303
#define CT_FTP_REPORT_OFF       0x1304
#define CT_REBOOT_DEVICE        0x1305
#define CT_REMOTE_SSH_ON        0x1306
#define CT_REMOTE_SSH_OFF       0x1307
#define CT_GSM_SNIFFER_ON		0x1308
#define CT_GSM_SNIFFER_OFF		0x1309

#define CT_SCANMODE_ON          0x3000
#define CT_SCANMODE_OFF         0x3001
#define CT_LOCATION_ON          0x3002
#define CT_LOCATION_OFF         0x3003


//CMD_CONFIG CODES
#define CFG_BASE				0x10a0
#define CFG_WIRELESS			0x10a1
#define CFG_PA_GAIN				0x10a2
#define CFG_INTERFACE			0x10a3
#define CFG_STOR				0x10a4
#define CFG_AIR_SNIFFER			0x10a5
#define CFG_TRANSERS			0x10a6
#define CFG_SMS_TEMPLATES		0x10a7
#define CFG_REPASS				0x10a8
//#define CFG_INTERFACE         0x10a9
#define CFG_INT_MANG_ADD		0x10aa
#define CFG_INT_MANG_DEL		0x10ab
#define CFG_INT_UP_ADD			0x10ac
#define CFG_INT_UP_DEL			0x10ad
//#define CFG_TIME_SRV          0x10ae
#define CFG_SOFTWARE_UPDATA		0x10af

#define SY_BLACKLIST            0x10d0
#define SY_WHITELIST            0x10d1
#define CFG_DATA_CLEAN          0x10b1
#define CFG_STATUS_INTVL		0x10b2
#define CFG_DET_INTVL			0x10b3
#define CFG_DATA_INTVL			0x10ae

#define CFG_DATA_UP             0x10b5
#define CFG_SMS_KEY             0x10b6
#define CFG_UPDATA_TAC_CYCLE    0x10b7
#define CFG_SR_DATA_CYCLE       0x10b8

#define CFG_TOTAL_CELL          0x1389

#define CFG_POWER               5000
#define CFG_GSM_WIRELESS        6001
#define CFG_CELL_UPDATE         0X10b9
#define CFG_DEVICE_MODE         0x10ba
#define CFG_WORK_PERIOD         0x10bb
#define CFG_GPS_DELAY           0x10bc
#define CFG_FTP_INFO            0x10bd
#define CFG_RESTART_TIME        0x10be
#define CFG_NTP_SERVER          0x10bf
#define CFG_BLACKLIST_ADD		0x1400
#define CFG_BLACKLIST_DEL		0x1401

#define CFG_ALL_BBU_CONFIG      0x3100
#define CFG_FDD_MODE            0x3101

//CMD_SEARCH CODES
#define SR_STATS				0x10c0
#define SR_DATA					0x10c1
#define SR_RES_PER				0x10c2
#define SR_BLACKLIST			0x10c3
#define SR_WHITELIST			0x10c4
#define SR_GPSINFO              0x10c5
#define SR_DEV_VERSION          0x10c6
#define SR_RRU_PA_NUMBER        0x10c9
#define SR_EUTRAN_VERSION       0x10ca
#define SR_LOG_INFO             0x10cc
#define SR_BBU_CFG              0x1108
#define SR_CURRENT_FREQ         0x1107
#define SR_DEVICE_LOG           0x1109
#define SR_FTP_INFO             0x110a
#define SR_X86_CFG              0x110b
#define SR_X86_CURRENT_TIME     0x110c
#define SR_RESTART_TIME         0x110d
#define SR_NTP_SERVER           0x110e
#define SR_GSM_SNIFFER_TIME     0x110f
#define SR_TIME_REPEAT          0x1110
#define SR_TAC_CYCLE            0x1111
#define SR_BBU_VERSION          0x1112
#define	SR_HW_ID				0x1114
#define SR_SERVER_RESART_SNF	0x1115
#define SR_BOARDCARD_INFO		0x1116

#define SR_TOTAL_CFG        	0x2000

#define SR_ALL_BBU_CONFIG       0x3200
#define SR_DEVICE_USAGE         0x3201
#define SR_LOCATION_STATUS      0x3202

#define CFG_LOCATION_CELL       0x10d4
#define CFG_ALL_CELL            0x10d6
#define SR_BBU_STATE            0x10d5
           

#define CT_UE_REDIRECT_ON       0x10d2
#define CT_UE_REDIRECT_OFF      0X10d3                    

#define CFG_UEID_FILTER_ON      0x10d7
#define CFG_UEID_FILTER_OFF     0x10d8






//HEARTBEAT CLIENT STATUS CODES
#define HT_CL_STATUS_OK			0x1000
#define HT_CL_STATUS_EX			0x1001
//----------might wrong value, just put here.
#define HT_CL_STATUS_START		0x1002
#define HT_CL_STATUS_END		0x1003
#define HT_CL_STATUS_DOING		0x1004
//----------End.
#define HT_CL_EX_SMS			0x1010
#define HT_CL_EX_WIRELISS		0x1011
#define HT_CL_EX_VSWR			0x1012
#define HT_CL_EX_PA				0x1013
#define HT_CL_EX_TEPMER			0x1014
#define HT_CL_EX_UPSRV			0x1015
#define HT_CL_EX_OTHER			0x1016
//HEARTBAET SERVER STATUS CODES
#define HT_SRV_STATUS_OK		0x1020
#define HT_SRV_STATUS_EX		0x1021
#define HT_SRV_AUTH_FAIL		0x0030
#define HT_SRV_FCUT_CONN		0x0031
#define HT_SRV_STARING			0x0032
#define HT_SRV_RESTAT			0x0033
#define HT_SRV_OTHER			0x0034
//MANAGEMENT RETURN CODE

#define RST_SUCESS				0x1050
#define RST_DOING				0x1051
#define RST_FAILED				0x1052

//Other strings and codes:
//AUTH commands
#define SRV_ACT_LOGIN_STR		"login"
#define SRV_ACT_DEVREG_STR		"devreg"
#define SRV_ACT_OUT_STR			"out"
#define SRV_ACT_KEEP_STR		"keep"

#define SRV_RPL_ERR_STR			"code"
#define SRV_RPL_SUCCESS_STR		"skey"
#define CODE_0001				0x0001
#define CODE_0002				0x0002
#define SKEY_LEN				40  //it might be changed
#define SKEY_TOTAL_LEN			51  //40 + 2 +4 + 4 + 1

//code level define
//CMD minimal length 256 bytes.
#define CMD_LENGTH_MIN			0x100

//
#define EXT_AC_DELAY			0x0001
#define EXT_AC_STARTTIME		0x0002
#define EXT_AC_ENDTIME			0x0003
#define EXT_AC_BASE_INFO		0x0004
#define EXT_AC_BTS1				0x0005
#define EXT_AC_BTS2				0x0006
#define EXT_AC_SMS_TMP			0x0007
#define EXT_AC_IF_INFO			0x0008
#define EXT_AC_URL				0x0009
#define EXT_RES_INFO			0x000a
#define EXT_BLACK_LIST			0x000b
#define EXT_WHITE_LIST			0x000c

#define WR_VSWR					0x1100
#define WR_RF_MODULE			0x1101
#define WR_NETWORK				0x1102
#define WR_SMS_MODULE			0x1103
#define WR_PA_HIGH_TEMP			0x1104
#define WR_DEV_POWER			0x1105
#define WR_DEV_MOVE				0x1106
#define WR_POWEROFF				0x1107
#define WR_DEV_RESTART			0x1108
#define WR_DEV_BOX_OPEN         0x1109
#define WR_DEV_LINE_BREAK       0x110a   

#define WR_BBU_HEARTBEAT_BBU1   0x1201
#define WR_BBU_HEARTBEAT_BBU2   0x1202
#define WR_BBU_HEARTBEAT_BBU3   0x1203
#define WR_BBU_HEARTBEAT_BBU4   0x1204
#define WR_BBU_HEARTBEAT_BBU5   0x1205
#define WR_BBU_HEARTBEAT_BBU6   0x1206
#define WR_BBU_HEARTBEAT_BBU7   0x1207
#define WR_BBU_HEARTBEAT_GSM    0x1208
#define WR_BBU_HEARTBEAT_CDMA   0x1209
#define WR_BBU_HEARTBEAT_WCDMA  0x120a
#define WR_BBU_HEARTBEAT_TDSCDMA 0x120b

#define WR_BBU1_NOT_RECV_IMSI   0x120c
#define WR_BBU2_NOT_RECV_IMSI   0x120d
#define WR_BBU3_NOT_RECV_IMSI   0x120e
#define WR_BBU4_NOT_RECV_IMSI   0x120f
#define WR_BBU5_NOT_RECV_IMSI   0x1210
#define WR_BBU6_NOT_RECV_IMSI   0x1211
#define WR_BBU7_NOT_RECV_IMSI   0x1212
#define WR_GSM_NOT_RECV_IMSI    0x1213
#define WR_CDMA_NOT_RECV_IMSI   0x1214
#define WR_WCDMA_NOT_RECV_IMSI  0x1215
#define WR_TDSCDMA_NOT_RECV_IMSI  0x1216

#define WR_LTE_BBU_GPS_LOST     0x1217
#define WR_BBU1_NSYNC           0x1218
#define WR_BBU2_NSYNC           0x1219
#define WR_BBU3_NSYNC           0x121a
#define WR_BBU4_NSYNC           0x121b
#define WR_BBU5_NSYNC           0x121c
#define WR_BBU6_NSYNC           0x121d
#define WR_BBU7_NSYNC           0x121e
#define WR_DEV_GPS              0x121f
#define WR_DEV_POWER_ON         0X1220

#define WR_PA1_SWR_WARN         0x1221
#define WR_PA2_SWR_WARN         0x1222
#define WR_PA3_SWR_WARN         0x1223
#define WR_PA4_SWR_WARN         0x1224
#define WR_PA5_SWR_WARN         0x1225
#define WR_PA6_SWR_WARN         0x1226
#define WR_PA7_SWR_WARN         0x1227
#define WR_PA8_SWR_WARN         0x1228
#define WR_PA9_SWR_WARN         0x1229
#define WR_PA10_SWR_WARN        0x122a
#define WR_PA11_SWR_WARN        0x122b
#define WR_PA12_SWR_WARN        0x122c 

#define WR_BBU1_LOST            0x122d
#define WR_BBU2_LOST            0x122e
#define WR_BBU3_LOST            0x122f
#define WR_BBU4_LOST            0x1230
#define WR_BBU5_LOST            0x1231
#define WR_BBU6_LOST            0x1232
#define WR_BBU7_LOST            0x1233
#define WR_GSM_LOST             0x1234
#define WR_CDMA_LOST            0x1235
#define WR_WCDMA_LOST           0x1236
#define WR_TDSCDMA_LOST         0x1237

#define WR_PA1_TEMP_WARN		0x1238
#define WR_PA2_TEMP_WARN		0x1239
#define WR_PA3_TEMP_WARN		0x123a
#define WR_PA4_TEMP_WARN		0x123b
#define WR_PA5_TEMP_WARN		0x123c
#define WR_PA6_TEMP_WARN		0x123d
#define WR_PA7_TEMP_WARN		0x123e
#define WR_PA8_TEMP_WARN		0x123f
#define WR_PA9_TEMP_WARN		0x1240
#define WR_PA10_TEMP_WARN		0x1241
#define WR_PA11_TEMP_WARN		0x1242
#define WR_PA12_TEMP_WARN		0x1243

#define SEX_AUTH_FAILD			0x0030
#define SEX_FCUT_CONN			0x0031
#define SEX_STARING				0x0032
#define SEX_RESTART				0x0033
#define SEX_OTHER				0x0034
#define SEX_UN_REG				0x0035
#define SEX_REG_SUCCESS			0x0036
#define SEX_MSG_FMT_ERROR		0x0037



#define DEVICE_STATUS           0x2001
#define SRV_RSP_MSG             0x2002 
#define SNF_RESULT              0x2003
#define DEVICE_REQ_TIMESYNC     0x2004
#define BLACKLIST_ALERT         0x2005
#define DEVICE_REQ_BTS_INFO     0x2006
#define SEARCH_ONE_RECORD       0x2007
#define SR_50_DAY_RECORD        0x2008
#define SR_ONE_DAY_RECORD       0x2009
#define SR_RECORD_BY_SEQ        0x200a
#define SR_RECORD_END           0x200b
#define SEND_UPGRADE_PACKET     0x200c
#define SEND_PACKET_END         0x200d
I32 cmd_get_upload_srctime(I8 *buf);
I32 cmd_gen_devinfo_string(DEV_INFO * info, U16 reconnectCode, I8 * buf);
I32 cmd_gen_gpsstatus_string(GPSINFO * gpsInfo, I8 * buf);
I32 cmd_handle_mng_heartbeat_string(I8 * buf);
I32 cmd_gen_mng_heartbeat_string(I8 * buf, I8 *devNum, I32 addDevNum, U32 buf_len, U32 state, I8 * msg);
I32 cmd_handle_mng_msg(I32 devType, I8 * buf, I32 length, I32 * conf, I32 * code, I32 *cmd_type);
I32 cmd_gen_mng_response(I8 * buf, U32 buf_len, U32 state, I8 * reason, I32 code, I32 type, COMMANDLIST cmdList);
//I32 cmd_gen_data_upload(I8 *buf, U32 buf_len, I32 *data);
I32 cmd_gen_data_upload(UPDATA_CACHE * cache, PHONE_TMP * tmp, I32 tmp_off);
I32 cmd_gen_data_upload_end(UPDATA_CACHE * cache, I8 *devNum);
I32 cmd_handle_data_msg(I8 * buf, I32 length);
I32 cmd_handle_upload_result(I8 * buf);
I32 cmd_gen_warning(I32 code, I8 * buf, I8 * msg);
I32 cmd_handle_register_msg(I8 * buf, I32 length);
I32 cmd_check_msg_num(I8 *buf, I32 buf_len);
I32 cmd_gen_sys_info_string(SYS_INFO *sysInfo, I8 * buf);
I32 cmd_up_current_data(I8 *data, RECORDINFO *record);

I32 cmd_gen_devstatus_string(I32 devType ,DEV_STATUS * status, I8 * buf, DEV_CONF *conf);
I32 cmd_handle_upload_cfg_result(I8 *buf);
I32 cmd_gen_snf_result(I32 type, I8 * buf, I32 * data);

I32 cmd_gen_bbu_info_string(DEV_CONF * devInfo, DEV_STATUS* status , I8 *buf);

I32 cmd_gen_total_bbu_info_string(DEV_CONF * devInfo,I8 *buf);

I32 cmd_handle_statistics_intvl(I8 *buf, I32 *num);

I32 count_every_bbu_upload_num(I8 *buf, I32 upload_num, I32 cellNum, I32 serialNum);
I32 cmd_gen_gsm_sniff_result(I8 *buf, I8 *data);
I32 cmd_gen_sr_local_response(I32 type, I8 *buf, I8 *data, DEV_CONF *dev_conf);


I32 cmd_gen_local_config_response(I32 type, I8 *buf, DEV_CONF* dev_conf);

I32 cmd_gen_all_bbu_state(BBU_STATUS *bbu_status,I8 * buf, I32 *slotID);


I32 cmd_up_mac_current_data(I8 *data, MACRECORDINFO *record);
I32 cmd_hanldle_device_requestMsg(I32 type, I32 code, I8 *buf);
I32 packBlackList(I8 *buf,  PHONE_TMP * tmp);
I32 cmd_gen_blackList(I8 *buf, PHONEINFO *phone);
I32 pack_ftp_current_data(I8 *data, PHONE_TMP *tmp);
I32 cmd_gen_warning_with_data(I32 code, I8 * buf, I8 * data);
I32 cmd_gen_sniff_result(I8 *buf, I8 *data);
I32 cmd_gen_bbu_version(I8 *buf, I8 *version ,I32 bbu);
void cmd_gen_ftp_devstatus(I8 *Mac, I8 *buf);
void cmd_gen_ftp_sitestatus(I8 *buf);
I32 cmd_gen_hw_id(I8 *buf);
I32 cmd_gen_server_restart_snf(DEV_CONF *dev_conf, I8 *buf);
I32 cmd_gen_boardcard_info(DEV_CONF *dev_conf, I8 *data, I8 *buf);

I32	cmd_gen_gpsboardstatus_string(GPSBOARDINFO * gpsInfo, I8 * buf);

I32 cmd_check_is_rebootCmd(I8 *buf);
I32 cmd_gen_delay_report(I8 *buf, DELAY_REPORT *delay_report);
I32 cmd_gen_device_usage(U32 *currentTm, U32 *startTm, U32 *endTm, I32 *len, I8 *buf, I8 *data);
I32 cmd_gen_location_status(DEV_STATUS * status, I8 * buf, DEV_CONF *conf);
#define SNF_RESULT_MANUAL		0x0
#define SNF_RESULT_AUTO			0x1


#endif
